import java.util.ArrayList;
import java.util.List;

public class StrategyPatternTest {
    public static void main(String[] args) {
        List<Employee> list = new ArrayList<>();
        list.add(new Employee(3,"zhangsan",12));
        list.add(new Employee(2,"lisi", 19));
        list.add(new Employee(1,"wangwu", 20));
        List<Employee> sort1 = sort(list, false, new SortByAge());

        for (Employee employee : sort1) {
            System.out.println(employee);
        }

        System.out.println("-----------------");
        List<Employee> sort2 = sort(list, false, new SortById());
        for (Employee employee : sort2) {
            System.out.println(employee);
        }

    }

    public static List<Employee> sort(List<Employee> list, Boolean asc, SortPredicate sortPredicate) {
        return sortPredicate.sort(list, asc);
    }
}